const service = require("../service/comment.service")

class commentController {
  async create(ctx,next){
    const {momentId,content} = ctx.request.body;
    const {id} = ctx.user;
    ctx.body = await service.create(momentId,content,id)
  }

  async reply(ctx,next){
    const {momentId,content} = ctx.request.body;
    const {commentId} = ctx.request.params;
    const {id} = ctx.user;
    ctx.body  = await service.reply(momentId,content,commentId,id)
  }

  async update(ctx,next){
    const {commentId} = ctx.params;
    const {content} = ctx.request.body;
    ctx.body = await service.update(commentId,content)
  }

  async remove(ctx,next){
    const {commentId} = ctx.request.params;
    ctx.body = await service.remove(commentId)
  }

  async list(ctx,next){
    const {momentId} = ctx.request.query;
    ctx.body = await service.getCommentList(momentId)
  }
}


module.exports = new commentController()